package com.woniuxy.springdataredis.controller;

import com.woniuxy.springdataredis.entity.User;
import com.woniuxy.springdataredis.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * description: UserController <br>
 * date: 2022/1/6 1:21 下午 <br>
 * author: shesaifei <br>
 * version: 1.0 <br>
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @GetMapping("/all")
    public List<User> all() {
        return userService.findAll();
    }

    @GetMapping("/id/{id}")
    public User findById(@PathVariable("id") int id) {
        System.out.println("controller接受处理请求");
        return userService.findById(id);
    }

    @GetMapping("/del/{id}")
    public boolean delById(@PathVariable("id") int id) {

        return userService.delById(id);
    }
}
